package fr.afcepf.iziticket.services;

import java.util.List;

import fr.afcepf.iziticket.beans.MainManagedBean;
import fr.afcepf.iziticket.dao.interfaces.DAOCommande;
import fr.afcepf.iziticket.entities.Commande;
import fr.afcepf.iziticket.entities.Reservation;

public class ConfirmationCommandeService {

	public void init(int idClient, List<Reservation> reservations){
		
		DAOCommande daoC = (DAOCommande)MainManagedBean.getContext().getBean("daoCommande");
		List<Commande> liste = daoC.getCommandesByUtilisateur(idClient);
		Commande commande = liste.get(liste.size()-1);
		for (Reservation res : commande.getReservations()) {
			reservations.add(res);
		}	
	
	}
	
	private static ConfirmationCommandeService service;
	
	public static ConfirmationCommandeService getService(){
		if(service==null)
			service = new ConfirmationCommandeService();
		return service;
	}
	
	private ConfirmationCommandeService() {
	}		
}
